
	/***********************************************************************************************

		@API
		Object: console

		Api:
			msg			console						(msg, params..)
			msg			console.debug			(msg, params..)
			msg			console.log				(msg, params..)
			msg			console.info			(msg, params..)
			msg			console.warn			(msg, params..)
			msg			console.error			(msg, params..)

	************************************************************************************************/

	;(function() {
		try {
			//-------------------------------------------------------------------------------
			jsl.console	= function() {
				try 			{ return jsl.console.log.apply(jsl.console, arguments) 	}
				catch(e) 	{ jsl.throwError(e, this, arguments) 										}
			}

			jsl.console.__name = "jsl.console"
		}
		catch(e) {
			jsl.throwError(e, "jsl.console")
		}
	})()

	//-------------------------------------------------------------------------------
	jsl.console.debug = function(msg) {
		try {
			var s, e//!
			if(!arguments.length)	throw jsl.ParamError()//!

			s = msg + ""

			if(s)
			if(jsl.message("debug." + s))
				s = jsl.message("debug." + s, Array.prototype.slice.call(arguments, 1))

			else if(jsl.message(s))
				s = jsl.message(s, Array.prototype.slice.call(arguments, 1))

			else if(arguments.length > 1)
				s	= this.__cmp(s, arguments)

			if(jsl.__log === "debug") {
				e	= new jsl.Event({ type: "debug", message: s  })
				jsl.throwEvent("beforeLog", e)
				jsl.__ni_cns_debug(s)
				jsl.throwEvent("log", e)
			}
			return s
		}
		catch(e) {
			jsl.throwError(e, this, arguments)
		}
	}
	//-------------------------------------------------------------------------------
	jsl.console.log = function(msg) {
		try {
			var s, e//!
			if(!arguments.length)	throw jsl.ParamError()//!

			s = msg + ""

			if(s)
			if(jsl.message("log." + s))
				s = jsl.message("log." + s, Array.prototype.slice.call(arguments, 1))

			else if(jsl.message(s))
				s = jsl.message(s, Array.prototype.slice.call(arguments, 1))

			else if(arguments.length > 1)
				s	= this.__cmp(s, arguments)

			if(jsl.Object.isIn(jsl.__log, "debug", "log")) {
				e	= new jsl.Event({ type: "log", message: s  })
				jsl.throwEvent("beforeLog", e)
				jsl.__ni_cns_log(s)
				jsl.throwEvent("log", e)
			}
			return s
		}
		catch(e) {
			jsl.throwError(e, this, arguments)
		}
	}
	//-------------------------------------------------------------------------------
	jsl.console.info = function(msg) {
		try {
			var s, e//!
			if(!arguments.length)	throw jsl.ParamError()//!

			s = msg + ""

			if(s)
			if(jsl.message("info." + s))
				s = jsl.message("info." + s, Array.prototype.slice.call(arguments, 1))

			else if(jsl.message(s))
				s = jsl.message(s, Array.prototype.slice.call(arguments, 1))

			else if(arguments.length > 1)
				s	= this.__cmp(s, arguments)

			if(jsl.Object.isIn(jsl.__log, "debug", "log", "info")) {
				e	= new jsl.Event({ type: "info", message: s  })
				jsl.throwEvent("beforeLog", e)
				jsl.__ni_cns_info(s)
				jsl.throwEvent("log", e)
			}
			return s
		}
		catch(e) {
			jsl.throwError(e, this, arguments)
		}
	}
	//-------------------------------------------------------------------------------
	jsl.console.warn = function(msg) {
		try {
			var s, e//!
			if(!arguments.length)	throw jsl.ParamError()//!

			s = msg + ""

			if(s)
			if(jsl.message("warn." + s))
				s = jsl.message("warn." + s, Array.prototype.slice.call(arguments, 1))

			else if(jsl.message(s))
				s = jsl.message(s, Array.prototype.slice.call(arguments, 1))

			else if(arguments.length > 1)
				s	= this.__cmp(s, arguments)

			if(jsl.Object.isIn(jsl.__log, "debug", "log", "info", "warn")) {
				e	= new jsl.Event({ type: "warn", message: s  })
				jsl.throwEvent("beforeLog", e)
				jsl.__ni_cns_warn(s)
				jsl.throwEvent("log", e)
			}
			return s
		}
		catch(e) {
			jsl.throwError(e, this, arguments)
		}
	}
	//-------------------------------------------------------------------------------
	jsl.console.error = function(msg) {
		try {
			var s, e//!
			if(!arguments.length)	throw jsl.ParamError()//!

			s = msg + ""

			if(s)
			if(jsl.message("e." + s))
				s = jsl.message("e." + s, Array.prototype.slice.call(arguments, 1))

			else if(jsl.message(s))
				s = jsl.message(s, Array.prototype.slice.call(arguments, 1))

			else if(arguments.length > 1)
				s	= this.__cmp(s, arguments)

			if(jsl.__log !== "none") {
				e	= new jsl.Event({ type: "error", message: s  })
				jsl.throwEvent("beforeLog", e)
				jsl.__ni_cns_error(s)
				jsl.throwEvent("log", e)
			}
			return s
		}
		catch(e) {
			jsl.throwError(e, this, arguments)
		}
	}
	//private
	//-------------------------------------------------------------------------------
	jsl.console.__cmp = function(s, ls) {
		var i = 1
		return s.replace(/(!*)\$/g, function(tk, g) {
			if(!g)								return ls[i++]
			else if(g.length % 2)	return g.slice(0, ~~(g.length / 2)) + "$"
			else									return g.slice(0, g.length / 2) + ls[i++]
		})
	}
